package servlettest;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/25.
 */
@WebServlet(name = "HServlet",urlPatterns = "/hs")
public class HServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        //设置响应编码方式
//        response.setCharacterEncoding("UTF-8");
//        //设置浏览器编码方式
//        response.setHeader("content-type","text/html;charset=utf-8");

        //执行上面两步
        response.setContentType("text/html;charset=utf-8");
        //3秒自动刷新
//        response.setHeader("refresh","3;//www.baidu.com");
        //重定向到指定页面
        response.sendRedirect("log/login.jsp");

        PrintWriter out = response.getWriter();
        out.write("httpservlet get... 啊哦额啊啊啊啊啊啊");
    }
}
